<?php

use yii\db\Migration;

/**
 * Class m210713_224420_news
 */
class m210713_224420_news extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        $this->execute("drop table if exists news;");
        $this->createTable("news", [
            'id' => $this->primaryKey(),
            'title' => $this->char(50)->notNull()->defaultValue("")->comment('the title of news'),
            'body' => $this->text()->notNull()->comment("the content of news")
        ]);
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->execute("drop table if exists news;");
        return true;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m210713_224420_news cannot be reverted.\n";

        return false;
    }
    */
}
